package org.dfl.core.model.transitions;

import java.util.ArrayList;

import org.dfl.core.data.connectors.CollectionTypeConnector;
import org.dfl.core.data.connectors.TypeConnector;
import org.dfl.core.data.types.Type;
import org.dfl.core.data.types.TypeManager;
import org.dfl.core.model.TransitionExecutionException;
import org.dfl.messages.Messages;

/**
 * transition that creates a multiset object with one element
 * @author Piotr Wlodarczyk
 *
 */
public class MultisetTransition extends OneInputTransition {

	@Override
	protected void connectInputAndOutput() {
		TypeConnector connector = new CollectionTypeConnector(getInputContainer(), getOutputTypeContainer());
		getOutputTypeContainer().connectBy(connector);
	}

	@Override
	protected Object fireSingle(Object input) throws TransitionExecutionException {
		ArrayList<Object> ret = new ArrayList<Object>();
		ret.add(input);
		return ret;
	}

	@Override
	protected Type getDefaultInputDefinition() {
		return TypeManager.getAnyType();
	}

	@Override
	protected Type getDefaultOutputDefinition() {
		return TypeManager.getCollectionType();
	}

	@Override
	public String getDefaultDescription() {
		return Messages.SingletonTransition_description;
	}

}
